while True:
	num = input()
	try:
		num = int(num)
		break
	except:
		print("again")
		continue


from vec import Vec2
import math
import random
import pgzrun

WIDTH = 500
HEIGHT = 500

PEN_COLOR = (0, 200, 0)
BACK_COLOR = (0, 0, 0)
ptList = []
length = 400
pt_mid = Vec2(WIDTH / 2, HEIGHT / 2)
pt_a = Vec2(pt_mid.x - 100, pt_mid.y - 100)
pt_b = Vec2(pt_mid.x - 100, pt_mid.y + 100)
pt_c = Vec2(pt_mid.x + 100, pt_mid.y + 100)
pt_d = Vec2(pt_mid.x + 100, pt_mid.y - 100)
ptList.append(pt_a)
ptList.append(pt_b)
ptList.append(pt_c)
ptList.append(pt_d)

def fractal(ptList):
    i = 0
    while True:
        if i == len(ptList) - 1:
            line_fractal(ptList, i, 0)
            break
        else:
            i = line_fractal(ptList, i, i + 1)

def line_fractal(ptList, a, b):
    dir = ptList[b] - ptList[a]
    step = dir.length() / 4
    dir.normalize()

    pt1 = ptList[a] * 3 / 4 + ptList[b] / 4
    vleftdir = Vec2(0, 0)
    vleftdir.x = -dir.y
    vleftdir.y = dir.x

    pt2 = pt1 + vleftdir * step

    vupdir = Vec2(0, 0)
    vupdir.x = vleftdir.y
    vupdir.y = -vleftdir.x

    pt3 = pt2 + vupdir * step

    vrightdir = Vec2(0, 0)
    vrightdir.x = vupdir.y
    vrightdir.y = -vupdir.x

    pt4 = pt3 + vrightdir * step

    pt5 = pt4 + vrightdir * step

    pt6 = pt5 + vupdir * step

    pt7 = pt6 + vleftdir * step

    ptList.insert(a + 1, pt7)
    ptList.insert(a + 1, pt6)
    ptList.insert(a + 1, pt5)
    ptList.insert(a + 1, pt4)
    ptList.insert(a + 1, pt3)
    ptList.insert(a + 1, pt2)
    ptList.insert(a + 1, pt1)

    return a + 8

for i in range(num):
   fractal(ptList)

def draw():
    screen.fill(BACK_COLOR)
    for i in range(len(ptList)):
        if i == len(ptList) - 1:
            screen.draw.line(
				ptList[i].raw_get(),
				ptList[0].raw_get(),
				PEN_COLOR
			)
        else:
            screen.draw.line(
				ptList[i].raw_get(),
				ptList[i + 1].raw_get(),
				PEN_COLOR
			)

pgzrun.go()
